﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using Login.Events;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;
using Telerik.Windows.Controls;

namespace Login.ViewModels
{
    [Export]
    public class LeftListPaneViewModel : BindableBase
    {
        public ICommand SelectionChangedCmd { get; }
        private IEventAggregator _eventAggregator;

        [ImportingConstructor]
        public LeftListPaneViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            SelectionChangedCmd = new DelegateCommand<RadTreeView>(ExecuteSelectionChangedCmd);
        }
        private void ExecuteSelectionChangedCmd(RadTreeView lst)
        {
            SeleItem = lst.SelectedItem as RadTreeViewItem;
            if(SeleItem==null) return;
            _eventAggregator.GetEvent<Refresh>().Publish(1);
            _eventAggregator.GetEvent<SelectChange>().Publish(SeleItem);
        }
        public RadTreeViewItem SeleItem { get; set; }
    }
}
